Data-file

Discrete data contained in a file can displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should contain one data point per line. Lines beginning with # (or ! on VMS) will be treated as comments and ignored. For plots, each data point represents an (x,y) pair. For splots, each point is an (x,y,z) triple. For plots with error bars (see plot errorbars), each data point is either (x,y,ydelta) or (x,y,ylow,yhigh). In all cases, the numbers on each line of a data file must be separated by blank space. This blank space divides each line into columns.

For plots the x value may be omitted, and for splots the x and y values may be omitted. In either case the omitted values are assigned the current coordinate number. Coordinate numbers start at 0 and are incremented for each data point read.

To specify other formats, see plot datafile using.

In the plot command, blank lines in the data file cause a break in the plot. There will be no line drawn between the preceding and following points if the plot style is lines or linespoints (see plot style). This does not change the plot style, as would plotting the data as separate curves.

This example compares the data in the file population.dat to a theoretical curve:

        pop(x) = 103*exp((1965-x)/10)
        plot [1960:1990] 'population.dat', pop(x)

The file population.dat might contain:

        # Gnu population in Antarctica since 1965
        1965   103
        1970   55
        1975   34
        1980   24
        1985   10

When a data file is plotted, samples and iso_samples are ignored. Curves plotted using the plot command are automatically extended to hold the entire curve. Similarly grid data plotted using the splot command is automatically extended, using the assumption that isolines are separated by blank lines (a line with only a CR/LF in it).

Implicitly, there are two types of 3-d datafiles. If all the isolines are of the same length, the data is assumed to be a grid data, i.e., the data has a grid topology. Cross isolines in the other parametric direction (the ith cross isoline passes thru the ith point of all the provided isolines) will also be drawn for grid data. (Note contouring is available for grid data only.) If all the isolines are not of the same length, no cross isolines will be drawn and contouring that data is impossible.

For splot if 3-d datafile and using format (see splot datafile using) specify only z (height field), a non parametric mode must be specified. If, on the other hand, x, y, and z are all specified, a parametric mode should be selected (see set parametric) since data is defining a parametric surface.

A simple example of plotting a 3-d data file is

        set parametric
        splot 'glass.dat'

or

        set noparametric
        splot 'datafile.dat'

where the file datafile.dat might contain:

        # The valley of the Gnu.
        10
        10
        10

        10
        5
        10

        10
        1
        10

        10
        0
        10

Note datafile.dat defines a 4 by 3 grid ( 4 rows of 3 points each ). Rows are separated by blank lines.

On some computer systems with a popen function (UNIX), the datafile can be piped through a shell command by starting the file name with a '<'. For example:

        pop(x) = 103*exp(x/10)
        plot '< awk "{print $1-1965 $2}" population.dat', pop(x)

would plot the same information as the first population example but with years since 1965 as the x axis.

For more information about 3-d plotting, see splot.


Subsections